<template>
	<view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,index) in list" :key="index" @click="addRoom(item)">
				<view class="uni-media-list">
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">{{item.room}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getRoomList} from "@/api/room.js";
	export default {
		data() {
			return {
				list:[],
				id:''
			}
		},
		onLoad(option){
			this.getList();
		},
		methods: {
			getList(){
				let community_id=this.$store.state.community.community_id;
				let group=this.$store.state.group.group;
				let building=this.$store.state.building.building;
				let unit=this.$store.state.unit.unit;
				getRoomList({community_id:community_id,group:group,building:building,unit:unit}).then((res)=>{
					console.log("res",res);
					if(res.data.code==0){
						this.list=res.data.data;
					}
				})
			},
			addRoom(item){
				this.$store.commit('setRoom',item);
				uni.navigateBack({
					delta:1
				})
			}
		}
		
	}
</script>

<style>
.uni-media-list-body{
	height: 45upx;
}
</style>
